package com.biodiv.community.controller;

import com.biodiv.community.client.OssClient;
import com.biodiv.community.service.CommonService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tianquan
 */
@RestController
@RequestMapping("/api/common")
@Tag(name = "通用接口")
@RequiredArgsConstructor
public class CommonController {

    private final CommonService commonService;

    @GetMapping("/sts-token")
    public OssClient.StsToken getStsToken() {
        try {
            return commonService.getOssSign();
        } catch (Exception e) {
            throw new RuntimeException("获取STS凭证失败", e);
        }
    }

}

